import {
  ADOPT_DIARY_AUDIT_STATUS_LIST,
  ADOPT_DIARY_AUDIT_STATUS,
} from '@/const/type';
import { getDiaryDate } from '@/util/date';
export const tableOption = {
  ...window.$crudMixins.tableOptions,
  addBtn: false,
  editBtn: false,
  delBtn: false,
  menuWidth: 120,
  viewBtn: false,
  column: [
    {
      label: '内容编号',
      prop: 'id',
      slot: true,
    },
    {
      label: '宠物编号',
      prop: 'petCode',
      slot: true,
      search: true,
    },
    {
      label: '昵称/曾用名',
      prop: 'petNickname',
      searchLabel: '宠物名称',
      search: true,
    },
    {
      label: '认养人',
      prop: 'adoptUserNickname',
      slot: true,
      search: true,
      width: 150,
    },
    {
      label: '动态内容',
      prop: 'content',
      overHidden: true,
    },
    {
      label: '创建时间',
      prop: 'createTime',
      type: 'date',
      width: 160,
      format: 'yyyy-MM-dd',
      valueFormat: 'yyyy-MM-dd HH:mm:ss',
      searchRange: true,
      searchSpan: 6,
      search: true,
    },
    {
      label: '发布时间',
      prop: 'releaseTime',
      type: 'date',
      width: 160,
      format: 'yyyy-MM-dd HH:mm:ss',
      valueFormat: 'yyyy-MM-dd HH:mm:ss',
      searchRange: true,
      searchSpan: 6,
      search: true,
    },
    {
      label: '反馈人员',
      prop: 'feedUserNickname',
    },
    {
      label: '审核状态',
      prop: 'status',
      type: 'select',
      dicData: ADOPT_DIARY_AUDIT_STATUS_LIST,
    },
  ],
};
//审核
export const auditReasonOption = {
  labelWidth: 120,
  submitBtn: false,
  emptyBtn: false,
  column: [
    {
      label: '审核结果',
      prop: 'status',
      type: 'radio',
      align: 'center',
      row: true,
      dicData: [
        {
          label: '通过',
          value: ADOPT_DIARY_AUDIT_STATUS.PASSED,
        },
        {
          label: '不通过',
          value: ADOPT_DIARY_AUDIT_STATUS.FAILED,
        },
      ],
      control: (val, form) => {
        if (val === ADOPT_DIARY_AUDIT_STATUS.PASSED) {
          return {
            auditRemark: {
              display: false,
            },
            releaseType: {
              display: true,
            },
            releaseDate: {
              display: false,
            },
          };
        } else {
          return {
            auditRemark: {
              display: true,
            },
            releaseType: {
              display: false,
            },
            releaseDate: {
              display: false,
            },
          };
        }
      },
      rules: [
        {
          required: true,
          message: '请选择审核结果',
          trigger: 'blur',
        },
      ],
    },
    {
      label: '',
      type: 'textarea',
      prop: 'auditRemark',
      row: true,
      placeholder: '请备注不通过原因',
      display: false,
      span: 24,
      showWordLimit: true,
      maxlength: 200,
      rules: [
        {
          required: true,
          message: '请选择审核结果',
          trigger: 'blur',
        },
      ],
    },
    {
      label: '实际发布时间',
      prop: 'releaseType',
      type: 'radio',
      align: 'center',
      row: true,
      value: '0',
      dicData: [
        {
          label: '立即发布',
          value: '0',
        },
        {
          label: '延迟发布',
          value: '1',
        },
      ],
      rules: [
        {
          required: true,
          message: '请选择实际发布时间',
          trigger: 'blur',
        },
      ],
      control: (val, form) => {
        if (val === '1') {
          return {
            releaseDate: {
              display: true,
            },
          };
        } else {
          return {
            releaseDate: {
              display: false,
            },
          };
        }
      },
    },
    {
      label: '',
      prop: 'releaseDate',
      display: false,
      span: 24,
      row: true,
      slot: true,
    },
  ],
};

export const detailOption = {
  labelWidth: 120,
  submitBtn: false,
  emptyBtn: false,
  detail: true,
  column: [
    {
      label: '创建时间',
      prop: 'createTime',
      row: true,
    },
    {
      label: '反馈人员',
      prop: 'feedUserNickname',
      row: true,
    },
    {
      label: '内容编号',
      prop: 'id',
      row: true,
    },
    {
      label: '宠物编号',
      prop: 'petCode',
      row: true,
    },
    {
      label: '宠物昵称/曾用名',
      prop: 'petNickname',
      row: true,
    },
    {
      label: '反馈时认养人',
      prop: 'adoptUserNickname',
      formslot: true,
    },
    {
      label: '用户编号',
      prop: 'adoptUserId',
    },
    {
      label: '动态内容',
      prop: 'content',
      row: true,
      span: 24,
    },
    {
      label: '动态图片/视频',
      prop: 'files',
      row: true,
      span: 24,
    },
    {
      label: '',
      prop: 'status',
      type: 'radio',
      display: false,
      hidden: true,
      dicData: ADOPT_DIARY_AUDIT_STATUS_LIST,
      control: (val, form) => {
        if (val === ADOPT_DIARY_AUDIT_STATUS.FAILED) {
          return {
            auditRemark: {
              display: true,
            },
          };
        } else {
          return {
            auditRemark: {
              display: false,
            },
          };
        }
      },
    },
    {
      label: '备注',
      prop: 'auditRemark',
      display: false,
      row: true,
    },
  ],
};
//统计
export const statisticsMonthOption = () => {
  return {
    ...window.$crudMixins.tableOptions,
    addBtn: false,
    editBtn: false,
    delBtn: false,
    menuWidth: 120,
    viewBtn: false,
    menu: true,
    column: [
      {
        label: '反馈人员',
        search: true,
        prop: 'feedUserNickname',
      },
      {
        label: '宠物昵称',
        search: true,
        prop: 'petNickname',
      },
      {
        label: '月份',
        prop: 'createTime',
        formatter: (row) => {
          return getDiaryDate(row.createTime, 'month');
        },
      },

      {
        label: '日记发布条数',
        prop: 'diaryCount',
      },
      {
        label: '审核不通过次数',
        prop: 'auditFailCount',
      },
    ],
  };
};

export const statisticsDayOption = () => {
  return {
    ...window.$crudMixins.tableOptions,
    addBtn: false,
    editBtn: false,
    delBtn: false,
    menuWidth: 120,
    viewBtn: false,
    menu: false,
    column: [
      {
        label: '反馈人员',
        search: true,
        prop: 'feedUserNickname',
      },
      {
        label: '宠物昵称',
        search: true,
        prop: 'petNickname',
      },
      {
        label: '日期',
        prop: 'createTime',
        formatter: (row) => {
          return getDiaryDate(row.createTime, 'day');
        },
      },

      {
        label: '日记发布条数',
        prop: 'diaryCount',
      },
    ],
  };
};
//审核不通过记录
export const auditFailOption = {
  ...window.$crudMixins.tableOptions,
  addBtn: false,
  editBtn: false,
  delBtn: false,
  menuWidth: 120,
  viewBtn: false,
  menu: true,
  column: [
    {
      label: '内容ID',
      prop: 'diaryId',
    },
    {
      label: '审核不通过次数',
      prop: 'auditFailCount',
    },
  ],
};
